<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    * {
      padding: 0;
      margin: 0;
      box-sizing: border-box;
    }

    html,
    body {
      width: 100vw;
      height: 100vh;
    }

    /*
      v-enter 是进入之前元素的状态
      v-leave-to 是元素离开之后  
    */

    .v-enter,
    .v-leave-to {
      opacity: 0;
      transform: translateX(150px);
    }

    /* 
      v-enter-active 入场动画的时间段
      v-leave-active 离开动画的时间段
     */
    .v-enter-active,
    .v-leave-active {
      transition: all 0.4s ease;
    }
  </style>
</head>

<body>
  <div id="app">
    <input type="button" value="点击" @click="add">
    <transition>
      <h1 v-show="flag">我们都是共产党员</h1>
    </transition>
  </div>
</body>
<script src="../js/vue.js"></script>
<script>
  /* 
  动画的实现:
    1.<transition></transition> 是官方提供的动画,把需要被动画的元素包裹起来
    2.自定义两组样式，来控制transition内部元素的实现动画
   */
  const vm = new Vue({
    el: "#app",
    data: {
      flag: true
    },
    methods: {
      add() {
        this.flag = !this.flag;
      }
    }
  });
</script>

</html>